﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Insert_Product : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    public void AddProduct(object s, EventArgs e)
    {
        Product p = new Product();
        ProductBOL pBOL = new ProductBOL();
        try
        {
            p.ProductID = txtProID.Text;
            p.ProductName = txtProductName.Text;
            p.Category = txtCategory.Text;
            p.UnitPrice = Convert.ToDouble(txtUnitPrice.Text);
            p.QuantityInStock = Convert.ToInt32(txtQuantityInStock.Text);
            p.Images = txtImage.Text;

            int result = pBOL.insertProduct(p);
            if (result > 0)
            {
                Label7.Text = "Insert record is successful!";
            }
            else
                Label7.Text = "Insert record is error";
        }
        catch (Exception ex)
        {
            Label7.Text = ex.Message;
        }
        finally
        {
            p = null;
            pBOL = null;
        }
    }

    protected void TextBox1_TextChanged(object sender, EventArgs e)
    {

    }
}